package com.rfs.design.chain.test;

import cn.hutool.core.util.StrUtil;
import com.rfs.design.chain.BusinessProcess;
import com.rfs.design.chain.ProcessContext;
import com.rfs.dto.ResponseDTO;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * 第一步检查
 * @author renfushuai
 * @date 2022/8/29
 */
@Service
public class PreParamCheckAction implements BusinessProcess<SendTaskDto> {
    @Override
    public void process(ProcessContext<SendTaskDto> context) {
        SendTaskDto sendTaskDto = context.getProcessModel();
        if (Objects.isNull(sendTaskDto)) {
            context.setNeedBreak(true).setResponse(ResponseDTO.error(100,"参数错误"));
            return;
        }
        if (StrUtil.isBlank(sendTaskDto.getMsgContext())) {
            context.setNeedBreak(true).setResponse(ResponseDTO.error(100,"短信内容不能为空"));
            return;
        }
        System.out.println("发送短信预检查完成");
    }
}
